package com.aaa.service.fpa.impl;

import cn.hutool.core.util.ObjectUtil;
import com.aaa.dao.fpa.QuestionFpaDao;
import com.aaa.entity.fpa.QuestionFpa;
import com.aaa.entity.system.PageOrder;
import com.aaa.service.fpa.QuestionFpaService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 问题表(QuestionFpa)表服务实现类
 *
 * @author makejava
 * @since 2022-08-31 08:46:02
 */
@Service
public class QuestionFpaServiceImpl implements QuestionFpaService {

    @Autowired
    private QuestionFpaDao questionFpaDao;

    @Override
    public Page queryAll(PageOrder pageOrder, QuestionFpa questionFpa) {
        PageHelper.startPage(pageOrder.getPage(), pageOrder.getLimit());
        if (ObjectUtil.isNotEmpty(pageOrder.getField())) {
            PageHelper.orderBy(pageOrder.getFieldOrder());
        }
        List<QuestionFpa> list = questionFpaDao.queryAll(questionFpa);
        Page pageResult = (Page) list;
        return pageResult;

    }

    /**
     * 添加
     * @param questionFpa 实例对象
     * @return
     */
    @Override
    public int insert(QuestionFpa questionFpa) {
        int insert = questionFpaDao.insert(questionFpa);
        return insert;
    }

    /**
     * 修改
     * @param questionFpa
     * @return
     */
    @Override
    public int updateUser(QuestionFpa questionFpa) {
        int update = questionFpaDao.update(questionFpa);
        return  update;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(int[] id) {
        return questionFpaDao.deleteById(id);
    }

    /**
     * 查询名字是否重复
     * @param questionFpa
     * @return
     */
    @Override
    public boolean repetitionName(QuestionFpa questionFpa) {
        Integer integer = questionFpaDao.repetitionName(questionFpa);
        if (integer==0){
            return true;
        }else {
            return  false;
        }
    }
}
